<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:body>

	<p:dataTable id="courseTable" var="item" paginator="true"
		paginatorTemplate="{CurrentPageReport}  {FirstPageLink}
		{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
		rows="5" value="#{mbDepartment.courses}" rowKey="#{item.id}"
		selection="#{mbDepartment.courseSelected}" selectionMode="single">

		<p:ajax event="rowSelect" listener="#{mbDepartment.onCourseRowSelect}"
			update=":departmentForm:tabView:courseCommandPanel">
		</p:ajax>

		<p:column>
			<f:facet name="header">
				<h:outputText value="Mã Môn Học" />
			</f:facet>
			<h:outputText value="#{item.courseId}" />
		</p:column>
		<p:column>
			<f:facet name="header">
				<h:outputText value="Tên Môn Học" />
			</f:facet>
			<h:outputText value="#{item.name}" />
		</p:column>
		<p:column>
			<f:facet name="header">
				<h:outputText value="Mã Khoa" />
			</f:facet>
			<h:outputText value="#{item.depId}" />
		</p:column>

		<p:column>
			<f:facet name="header">
				<h:outputText value="Mã Chuyên Ngành" />
			</f:facet>
			<h:outputText value="#{item.majorId}" />
		</p:column>

		<p:column>
			<f:facet name="header">
				<h:outputText value="Thuộc Học Kỳ" />
			</f:facet>
			<h:outputText value="#{item.semester}" />
		</p:column>


		<p:column>
			<f:facet name="header">
				<h:outputText value="Môn Bắt Buộc" />
			</f:facet>
			<p:selectBooleanCheckbox value="#{item.isrequired}" disabled="false"
				immediate="true" />
		</p:column>

		<p:column>
			<f:facet name="header">
				<h:outputText value="Số Chỉ Lý Thuyết" />
			</f:facet>
			<h:outputText value="#{item.theoryUnit}" />
		</p:column>
		<p:column>
			<f:facet name="header">
				<h:outputText value="Số Chỉ Thục Hành" />
			</f:facet>
			<h:outputText value="#{item.practiseUnit}" />
		</p:column>
		<p:column>
			<f:facet name="header">
				<h:outputText value="Kiểm Tra Giữa Kỳ" />
			</f:facet>
			<p:selectBooleanCheckbox value="#{item.isMidTest}" disabled="false"
				immediate="true" />
		</p:column>

		<p:column>
			<f:facet name="header">
				<h:outputText value="Đồ Án Môn Học" />
			</f:facet>
			<p:selectBooleanCheckbox value="#{item.isEssays}" disabled="false" />
		</p:column>

		<p:column>
			<f:facet name="header">
				<h:outputText value="Kiểm Tra Cuối Kỳ" />
			</f:facet>
			<p:selectBooleanCheckbox value="#{item.isFinalTest}" disabled="false" />
		</p:column>

	</p:dataTable>

	<h:panelGrid id="courseCommandPanel" columns="3">
		<p:commandButton id="addCourse" value="Thêm"
			disabled="#{mbDepartment.editMode == false}" update=":editCourseDlg"
			action="#{mbDepartment.prepareAddCourse}"
			oncomplete="editCourseDlgWidget.show()"></p:commandButton>
		<p:commandButton id="editCourse" value="Sửa"
			action="#{mbDepartment.prepareEditCourse}" update=":editCourseDlg"
			disabled="#{mbDepartment.courseSelected == null}"
			oncomplete="editCourseDlgWidget.show()"></p:commandButton>
		<p:commandButton id="deleteCourse" value="Xóa"
			action="#{mbDepartment.doDeleteCourse}"
			update="courseTable,courseCommandPanel"
			disabled="#{mbDepartment.courseSelected == null}">
		</p:commandButton>
	</h:panelGrid>

</h:body>

</html>